
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>TypeScript 2.2 · TypeScript Handbook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Patrick Zhong">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="TypeScript 2.1.html" />
    
    
    <link rel="prev" href="TypeScript 2.3.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../handbook/tutorials/">
            
                <a href="../handbook/tutorials/">
            
                    
                    快速上手
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../handbook/tutorials/TypeScript in 5 minutes.html">
            
                <a href="../handbook/tutorials/TypeScript in 5 minutes.html">
            
                    
                    5分钟了解TypeScript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../handbook/tutorials/ASP.NET Core.html">
            
                <a href="../handbook/tutorials/ASP.NET Core.html">
            
                    
                    ASP.NET Core
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../handbook/tutorials/ASP.NET 4.html">
            
                <a href="../handbook/tutorials/ASP.NET 4.html">
            
                    
                    ASP.NET 4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../handbook/tutorials/Gulp.html">
            
                <a href="../handbook/tutorials/Gulp.html">
            
                    
                    Gulp
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../handbook/tutorials/Knockout.html">
            
                <a href="../handbook/tutorials/Knockout.html">
            
                    
                    Knockout.js
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../handbook/tutorials/React & Webpack.html">
            
                <a href="../handbook/tutorials/React & Webpack.html">
            
                    
                    React与webpack
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../handbook/tutorials/React.html">
            
                <a href="../handbook/tutorials/React.html">
            
                    
                    React
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="../handbook/tutorials/Angular 2.html">
            
                <a href="../handbook/tutorials/Angular 2.html">
            
                    
                    Angular 2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9" data-path="../handbook/tutorials/Migrating from JavaScript.html">
            
                <a href="../handbook/tutorials/Migrating from JavaScript.html">
            
                    
                    从JavaScript迁移到TypeScript
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../handbook/">
            
                <a href="../handbook/">
            
                    
                    手册
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../handbook/Basic Types.html">
            
                <a href="../handbook/Basic Types.html">
            
                    
                    基础类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../handbook/Variable Declarations.html">
            
                <a href="../handbook/Variable Declarations.html">
            
                    
                    变量声明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../handbook/Interfaces.html">
            
                <a href="../handbook/Interfaces.html">
            
                    
                    接口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../handbook/Classes.html">
            
                <a href="../handbook/Classes.html">
            
                    
                    类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../handbook/Functions.html">
            
                <a href="../handbook/Functions.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../handbook/Generics.html">
            
                <a href="../handbook/Generics.html">
            
                    
                    泛型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="../handbook/Enums.html">
            
                <a href="../handbook/Enums.html">
            
                    
                    枚举
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.8" data-path="../handbook/Type Inference.html">
            
                <a href="../handbook/Type Inference.html">
            
                    
                    类型推论
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.9" data-path="../handbook/Type Compatibility.html">
            
                <a href="../handbook/Type Compatibility.html">
            
                    
                    类型兼容性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.10" data-path="../handbook/Advanced Types.html">
            
                <a href="../handbook/Advanced Types.html">
            
                    
                    高级类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.11" data-path="../handbook/Utilit Types.md">
            
                <span>
            
                    
                    实用工具类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.12" data-path="../handbook/Symbols.html">
            
                <a href="../handbook/Symbols.html">
            
                    
                    Symbols
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.13" data-path="../handbook/Iterators and Generators.html">
            
                <a href="../handbook/Iterators and Generators.html">
            
                    
                    Iterators 和 Generators
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.14" data-path="../handbook/Modules.html">
            
                <a href="../handbook/Modules.html">
            
                    
                    模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.15" data-path="../handbook/Namespaces.html">
            
                <a href="../handbook/Namespaces.html">
            
                    
                    命名空间
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.16" data-path="../handbook/Namespaces and Modules.html">
            
                <a href="../handbook/Namespaces and Modules.html">
            
                    
                    命名空间和模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.17" data-path="../handbook/Module Resolution.html">
            
                <a href="../handbook/Module Resolution.html">
            
                    
                    模块解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.18" data-path="../handbook/Declaration Merging.html">
            
                <a href="../handbook/Declaration Merging.html">
            
                    
                    声明合并
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.19" data-path="../handbook/Writing Definition Files.html">
            
                <a href="../handbook/Writing Definition Files.html">
            
                    
                    书写.d.ts文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.20" data-path="../handbook/JSX.html">
            
                <a href="../handbook/JSX.html">
            
                    
                    JSX
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.21" data-path="../handbook/Decorators.html">
            
                <a href="../handbook/Decorators.html">
            
                    
                    Decorators
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.22" data-path="../handbook/Mixins.html">
            
                <a href="../handbook/Mixins.html">
            
                    
                    混入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.23" data-path="../handbook/Triple-Slash Directives.html">
            
                <a href="../handbook/Triple-Slash Directives.html">
            
                    
                    三斜线指令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.24" data-path="../handbook/Type Checking JavaScript Files.html">
            
                <a href="../handbook/Type Checking JavaScript Files.html">
            
                    
                    JavaScript文件里的类型检查
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../handbook/declaration files/Introduction.html">
            
                <a href="../handbook/declaration files/Introduction.html">
            
                    
                    如何书写声明文件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../handbook/declaration files/Library Structures.html">
            
                <a href="../handbook/declaration files/Library Structures.html">
            
                    
                    结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../handbook/declaration files/Do's and Don'ts.html">
            
                <a href="../handbook/declaration files/Do's and Don'ts.html">
            
                    
                    规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../handbook/declaration files/By Example.html">
            
                <a href="../handbook/declaration files/By Example.html">
            
                    
                    举例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../handbook/declaration files/Deep Dive.html">
            
                <a href="../handbook/declaration files/Deep Dive.html">
            
                    
                    深入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../handbook/declaration files/Publishing.html">
            
                <a href="../handbook/declaration files/Publishing.html">
            
                    
                    发布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../handbook/declaration files/Consumption.html">
            
                <a href="../handbook/declaration files/Consumption.html">
            
                    
                    使用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../handbook/tsconfig.json.html">
            
                <a href="../handbook/tsconfig.json.html">
            
                    
                    工程配置
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../handbook/tsconfig.json.html">
            
                <a href="../handbook/tsconfig.json.html">
            
                    
                    tsconfig.json
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../handbook/Project References.html">
            
                <a href="../handbook/Project References.html">
            
                    
                    工程引用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../handbook/Typings for NPM Packages.html">
            
                <a href="../handbook/Typings for NPM Packages.html">
            
                    
                    NPM包的类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../handbook/Compiler Options.html">
            
                <a href="../handbook/Compiler Options.html">
            
                    
                    编译选项
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../handbook/Configuring Watch.html">
            
                <a href="../handbook/Configuring Watch.html">
            
                    
                    配置 Watch
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../handbook/Compiler Options in MSBuild.html">
            
                <a href="../handbook/Compiler Options in MSBuild.html">
            
                    
                    在MSBuild里使用编译选项
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="../handbook/Integrating with Build Tools.html">
            
                <a href="../handbook/Integrating with Build Tools.html">
            
                    
                    与其它构建工具整合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="../handbook/Nightly Builds.html">
            
                <a href="../handbook/Nightly Builds.html">
            
                    
                    使用TypeScript的每日构建版本
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../wiki/">
            
                <a href="../wiki/">
            
                    
                    Wiki
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../wiki/this-in-TypeScript.html">
            
                <a href="../wiki/this-in-TypeScript.html">
            
                    
                    TypeScript里的this
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../wiki/coding_guidelines.html">
            
                <a href="../wiki/coding_guidelines.html">
            
                    
                    编码规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../wiki/Common Errors.html">
            
                <a href="../wiki/Common Errors.html">
            
                    
                    常见编译错误
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../wiki/TypeScript-Editor-Support.html">
            
                <a href="../wiki/TypeScript-Editor-Support.html">
            
                    
                    支持TypeScript的编辑器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../wiki/Using-TypeScript-With-ASP.NET-5.html">
            
                <a href="../wiki/Using-TypeScript-With-ASP.NET-5.html">
            
                    
                    结合ASP.NET v5使用TypeScript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../wiki/Architectural-Overview.html">
            
                <a href="../wiki/Architectural-Overview.html">
            
                    
                    架构概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../wiki/Roadmap.html">
            
                <a href="../wiki/Roadmap.html">
            
                    
                    发展路线图
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="./">
            
                <a href="./">
            
                    
                    新增功能
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="TypeScript 3.1.html">
            
                <a href="TypeScript 3.1.html">
            
                    
                    TypeScript 3.1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="TypeScript 3.0.html">
            
                <a href="TypeScript 3.0.html">
            
                    
                    TypeScript 3.0
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="TypeScript 2.9.html">
            
                <a href="TypeScript 2.9.html">
            
                    
                    TypeScript 2.9
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="TypeScript 2.8.html">
            
                <a href="TypeScript 2.8.html">
            
                    
                    TypeScript 2.8
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="TypeScript 2.7.html">
            
                <a href="TypeScript 2.7.html">
            
                    
                    TypeScript 2.7
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.6" data-path="TypeScript 2.6.html">
            
                <a href="TypeScript 2.6.html">
            
                    
                    TypeScript 2.6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.7" data-path="TypeScript 2.5.html">
            
                <a href="TypeScript 2.5.html">
            
                    
                    TypeScript 2.5
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.8" data-path="TypeScript 2.4.html">
            
                <a href="TypeScript 2.4.html">
            
                    
                    TypeScript 2.4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.9" data-path="TypeScript 2.3.html">
            
                <a href="TypeScript 2.3.html">
            
                    
                    TypeScript 2.3
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.7.10" data-path="TypeScript 2.2.html">
            
                <a href="TypeScript 2.2.html">
            
                    
                    TypeScript 2.2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.11" data-path="TypeScript 2.1.html">
            
                <a href="TypeScript 2.1.html">
            
                    
                    TypeScript 2.1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.12" data-path="TypeScript 2.0.html">
            
                <a href="TypeScript 2.0.html">
            
                    
                    TypeScript 2.0
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.13" data-path="TypeScript 1.8.html">
            
                <a href="TypeScript 1.8.html">
            
                    
                    TypeScript 1.8
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.14" data-path="TypeScript 1.7.html">
            
                <a href="TypeScript 1.7.html">
            
                    
                    TypeScript 1.7
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.15" data-path="TypeScript 1.6.html">
            
                <a href="TypeScript 1.6.html">
            
                    
                    TypeScript 1.6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.16" data-path="TypeScript 1.5.html">
            
                <a href="TypeScript 1.5.html">
            
                    
                    TypeScript 1.5
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.17" data-path="TypeScript 1.4.html">
            
                <a href="TypeScript 1.4.html">
            
                    
                    TypeScript 1.4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.18" data-path="TypeScript 1.3.html">
            
                <a href="TypeScript 1.3.html">
            
                    
                    TypeScript 1.3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.19" data-path="TypeScript 1.1.html">
            
                <a href="TypeScript 1.1.html">
            
                    
                    TypeScript 1.1
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../breaking-changes/breaking-changes.html">
            
                <a href="../breaking-changes/breaking-changes.html">
            
                    
                    Breaking Changes
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../breaking-changes/TypeScript 2.4.html">
            
                <a href="../breaking-changes/TypeScript 2.4.html">
            
                    
                    TypeScript 2.4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../breaking-changes/TypeScript 2.3.html">
            
                <a href="../breaking-changes/TypeScript 2.3.html">
            
                    
                    TypeScript 2.3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../breaking-changes/TypeScript 2.2.html">
            
                <a href="../breaking-changes/TypeScript 2.2.html">
            
                    
                    TypeScript 2.2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../breaking-changes/TypeScript 2.1.html">
            
                <a href="../breaking-changes/TypeScript 2.1.html">
            
                    
                    TypeScript 2.1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="../breaking-changes/TypeScript 2.0.html">
            
                <a href="../breaking-changes/TypeScript 2.0.html">
            
                    
                    TypeScript 2.0
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.6" data-path="../breaking-changes/TypeScript 1.8.html">
            
                <a href="../breaking-changes/TypeScript 1.8.html">
            
                    
                    TypeScript 1.8
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.7" data-path="../breaking-changes/TypeScript 1.7.html">
            
                <a href="../breaking-changes/TypeScript 1.7.html">
            
                    
                    TypeScript 1.7
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.8" data-path="../breaking-changes/TypeScript 1.6.html">
            
                <a href="../breaking-changes/TypeScript 1.6.html">
            
                    
                    TypeScript 1.6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.9" data-path="../breaking-changes/TypeScript 1.5.html">
            
                <a href="../breaking-changes/TypeScript 1.5.html">
            
                    
                    TypeScript 1.5
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.10" data-path="../breaking-changes/TypeScript 1.4.html">
            
                <a href="../breaking-changes/TypeScript 1.4.html">
            
                    
                    TypeScript 1.4
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >TypeScript 2.2</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="typescript-22">TypeScript 2.2</h1>
<h2 id="&#x652F;&#x6301;&#x6DF7;&#x5408;&#x7C7B;">&#x652F;&#x6301;&#x6DF7;&#x5408;&#x7C7B;</h2>
<p>TypeScript 2.2 &#x589E;&#x52A0;&#x4E86;&#x5BF9; ECMAScript 2015 &#x6DF7;&#x5408;&#x7C7B;&#x6A21;&#x5F0F; (&#x89C1;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes#Mix-ins" target="_blank">MDN&#x6DF7;&#x5408;&#x7C7B;&#x7684;&#x63CF;&#x8FF0;</a>&#x53CA;<a href="http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/" target="_blank">JavaScript&#x7C7B;&#x7684;&quot;&#x771F;&quot;&#x6DF7;&#x5408;</a>&#x4E86;&#x89E3;&#x66F4;&#x591A;) &#x4EE5;&#x53CA;&#x4F7F;&#x7528;&#x4EA4;&#x53C9;&#x6765;&#x7C7B;&#x578B;&#x8868;&#x8FBE;&#x7ED3;&#x5408;&#x6DF7;&#x5408;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7684;&#x7B7E;&#x540D;&#x53CA;&#x5E38;&#x89C4;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7B7E;&#x540D;&#x7684;&#x89C4;&#x5219;.</p>
<h5 id="&#x9996;&#x5148;&#x662F;&#x4E00;&#x4E9B;&#x672F;&#x8BED;">&#x9996;&#x5148;&#x662F;&#x4E00;&#x4E9B;&#x672F;&#x8BED;</h5>
<p><strong>&#x6DF7;&#x5408;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7C7B;&#x578B;</strong>&#x6307;&#x4EC5;&#x6709;&#x5355;&#x4E2A;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7B7E;&#x540D;&#xFF0C;&#x4E14;&#x8BE5;&#x7B7E;&#x540D;&#x4EC5;&#x6709;&#x4E00;&#x4E2A;&#x7C7B;&#x578B;&#x4E3A; any[] &#x7684;&#x53D8;&#x957F;&#x53C2;&#x6570;&#xFF0C;&#x8FD4;&#x56DE;&#x503C;&#x4E3A;&#x5BF9;&#x8C61;&#x7C7B;&#x578B;. &#x6BD4;&#x5982;, &#x6709; X &#x4E3A;&#x5BF9;&#x8C61;&#x7C7B;&#x578B;, new (...args: any[]) =&gt; X &#x662F;&#x4E00;&#x4E2A;&#x5B9E;&#x4F8B;&#x7C7B;&#x578B;&#x4E3A; X &#x7684;&#x6DF7;&#x5408;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7C7B;&#x578B;&#x3002;</p>
<p><strong>&#x6DF7;&#x5408;&#x7C7B;</strong>&#x6307;&#x4E00;&#x4E2A;<code>extends</code>(&#x6269;&#x5C55;)&#x4E86;&#x7C7B;&#x578B;&#x53C2;&#x6570;&#x7C7B;&#x578B;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x7C7B;&#x58F0;&#x660E;&#x6216;&#x8868;&#x8FBE;&#x5F0F;. &#x4EE5;&#x4E0B;&#x89C4;&#x5219;&#x5BF9;&#x6DF7;&#x5408;&#x7C7B;&#x58F0;&#x660E;&#x9002;&#x7528;&#xFF1A;</p>
<ul>
<li><code>extends</code>&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x7C7B;&#x578B;&#x53C2;&#x6570;&#x7C7B;&#x578B;&#x5FC5;&#x987B;&#x662F;&#x6DF7;&#x5408;&#x6784;&#x9020;&#x51FD;&#x6570;.</li>
<li>&#x6DF7;&#x5408;&#x7C7B;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570; (&#x5982;&#x679C;&#x6709;) &#x5FC5;&#x987B;&#x6709;&#x4E14;&#x4EC5;&#x6709;&#x4E00;&#x4E2A;&#x7C7B;&#x578B;&#x4E3A;<code>any[]</code>&#x7684;&#x53D8;&#x957F;&#x53C2;&#x6570;, &#x5E76;&#x4E14;&#x5FC5;&#x987B;&#x4F7F;&#x7528;&#x5C55;&#x5F00;&#x8FD0;&#x7B97;&#x7B26;&#x5728;<code>super(...args)</code>&#x8C03;&#x7528;&#x4E2D;&#x5C06;&#x8FD9;&#x4E9B;&#x53C2;&#x6570;&#x4F20;&#x9012;&#x3002;</li>
</ul>
<p>&#x5047;&#x8BBE;&#x6709;&#x7C7B;&#x578B;&#x53C2;&#x6570;&#x4E3A;<code>T</code>&#x4E14;&#x7EA6;&#x675F;&#x4E3A;<code>X</code>&#x7684;&#x8868;&#x8FBE;&#x5F0F;<code>Bas</code>&#xFF0C;&#x5904;&#x7406;&#x6DF7;&#x5408;&#x7C7B;<code>class C extends Base {...}</code>&#x65F6;&#x4F1A;&#x5047;&#x8BBE;<code>Base</code>&#x6709;<code>X</code>&#x7C7B;&#x578B;&#xFF0C;&#x5904;&#x7406;&#x7ED3;&#x679C;&#x4E3A;&#x4EA4;&#x53C9;&#x7C7B;&#x578B;<code>typeof C &amp; T</code>&#x3002;&#x6362;&#x8A00;&#x4E4B;&#xFF0C;&#x4E00;&#x4E2A;&#x6DF7;&#x5408;&#x7C7B;&#x88AB;&#x8868;&#x8FBE;&#x4E3A;&#x6DF7;&#x5408;&#x7C7B;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7C7B;&#x578B;&#x4E0E;&#x53C2;&#x6570;&#x57FA;&#x7C7B;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7C7B;&#x578B;&#x7684;&#x4EA4;&#x53C9;&#x7C7B;&#x578B;.</p>
<p>&#x5728;&#x83B7;&#x53D6;&#x4E00;&#x4E2A;&#x5305;&#x542B;&#x4E86;&#x6DF7;&#x5408;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7C7B;&#x578B;&#x7684;&#x4EA4;&#x53C9;&#x7C7B;&#x578B;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7B7E;&#x540D;&#x65F6;&#xFF0C;&#x6DF7;&#x5408;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7B7E;&#x540D;&#x4F1A;&#x88AB;&#x4E22;&#x5F03;&#xFF0C;&#x800C;&#x5B83;&#x4EEC;&#x7684;&#x5B9E;&#x4F8B;&#x7C7B;&#x578B;&#x4F1A;&#x88AB;&#x6DF7;&#x5408;&#x5230;&#x4EA4;&#x53C9;&#x7C7B;&#x578B;&#x4E2D;&#x5176;&#x4ED6;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7B7E;&#x540D;&#x7684;&#x8FD4;&#x56DE;&#x7C7B;&#x578B;&#x4E2D;. &#x6BD4;&#x5982;&#xFF0C;&#x4EA4;&#x53C9;&#x7C7B;&#x578B;<code>{ new(...args: any[]) =&gt; A } &amp; { new(s: string) =&gt; B }</code>&#x4EC5;&#x6709;&#x4E00;&#x4E2A;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7B7E;&#x540D;<code>new(s: string) =&gt; A &amp; B</code>&#x3002;</p>
<h5 id="&#x5C06;&#x4EE5;&#x4E0A;&#x89C4;&#x5219;&#x653E;&#x5230;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#x4E2D;">&#x5C06;&#x4EE5;&#x4E0A;&#x89C4;&#x5219;&#x653E;&#x5230;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#x4E2D;</h5>
<pre><code class="lang-ts"><span class="hljs-keyword">class</span> Point {
    <span class="hljs-keyword">constructor</span>(public x: number, public y: number) {}
}

<span class="hljs-keyword">class</span> Person {
    <span class="hljs-keyword">constructor</span>(public name: string) {}
}

<span class="hljs-keyword">type</span> Constructor&lt;T&gt; = <span class="hljs-keyword">new</span>(...args: <span class="hljs-built_in">any</span>[]) =&gt; T;

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Tagged</span>&lt;<span class="hljs-title">T</span> <span class="hljs-title">extends</span> <span class="hljs-title">Constructor</span>&lt;</span>{}&gt;&gt;(Base: T) {
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">class</span> extends Base {
        _tag: <span class="hljs-built_in">string</span>;
        <span class="hljs-keyword">constructor</span>(...args: any[]) {
            <span class="hljs-keyword">super</span>(...args);
            <span class="hljs-keyword">this</span>._tag = <span class="hljs-string">&quot;&quot;</span>;
        }
    }
}

<span class="hljs-keyword">const</span> TaggedPoint = Tagged(Point);

<span class="hljs-keyword">let</span> point = <span class="hljs-keyword">new</span> TaggedPoint(<span class="hljs-number">10</span>, <span class="hljs-number">20</span>);
point._tag = <span class="hljs-string">&quot;hello&quot;</span>;

<span class="hljs-keyword">class</span> Customer extends Tagged(Person) {
    accountBalance: <span class="hljs-built_in">number</span>;
}

<span class="hljs-keyword">let</span> customer = <span class="hljs-keyword">new</span> Customer(<span class="hljs-string">&quot;Joe&quot;</span>);
customer._tag = <span class="hljs-string">&quot;test&quot;</span>;
customer.accountBalance = <span class="hljs-number">0</span>;
</code></pre>
<p>&#x6DF7;&#x5408;&#x7C7B;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x5728;&#x7C7B;&#x578B;&#x53C2;&#x6570;&#x4E2D;&#x9650;&#x5B9A;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7B7E;&#x540D;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x6765;&#x9650;&#x5236;&#x5B83;&#x4EEC;&#x53EF;&#x4EE5;&#x88AB;&#x6DF7;&#x5165;&#x7684;&#x7C7B;&#x7684;&#x7C7B;&#x578B;&#x3002;&#x4E3E;&#x4F8B;&#x6765;&#x8BF4;&#xFF0C;&#x4E0B;&#x9762;&#x7684;<code>WithLocation</code>&#x51FD;&#x6570;&#x5B9E;&#x73B0;&#x4E86;&#x4E00;&#x4E2A;&#x4E3A;&#x6EE1;&#x8DB3;<code>Point</code>&#x63A5;&#x53E3; &#xFF08;&#x4E5F;&#x5C31;&#x662F;&#x6709;&#x7C7B;&#x578B;&#x4E3A;<code>number</code>&#x7684;<code>x</code>&#x548C;<code>y</code>&#x5C5E;&#x6027;&#xFF09;&#x7684;&#x7C7B;&#x6DFB;&#x52A0;<code>getLocation</code>&#x65B9;&#x6CD5;&#x7684;&#x5B50;&#x7C7B;&#x5DE5;&#x5382;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> Point {
    x: <span class="hljs-built_in">number</span>;
    y: <span class="hljs-built_in">number</span>;
}

<span class="hljs-keyword">const</span> WithLocation = &lt;T extends Constructor&lt;Point&gt;&gt;(Base: T) =&gt;
    <span class="hljs-keyword">class</span> extends Base {
        getLocation(): [<span class="hljs-built_in">number</span>, <span class="hljs-built_in">number</span>] {
            <span class="hljs-keyword">return</span> [<span class="hljs-keyword">this</span>.x, <span class="hljs-keyword">this</span>.y];
        }
    }
</code></pre>
<h2 id="object&#x7C7B;&#x578B;"><code>object</code>&#x7C7B;&#x578B;</h2>
<p>TypeScript&#x6CA1;&#x6709;&#x8868;&#x793A;&#x975E;&#x57FA;&#x672C;&#x7C7B;&#x578B;&#x7684;&#x7C7B;&#x578B;&#xFF0C;&#x5373;&#x4E0D;&#x662F;<code>number</code> | <code>string</code> | <code>boolean</code> | <code>symbol</code> | <code>null</code> | <code>undefined</code>&#x7684;&#x7C7B;&#x578B;&#x3002;&#x4E00;&#x4E2A;&#x65B0;&#x7684;<code>object</code>&#x7C7B;&#x578B;&#x767B;&#x573A;&#x3002;</p>
<p>&#x4F7F;&#x7528;<code>object</code>&#x7C7B;&#x578B;&#xFF0C;&#x53EF;&#x4EE5;&#x66F4;&#x597D;&#x5730;&#x8868;&#x793A;&#x7C7B;&#x4F3C;<code>Object.create</code>&#x8FD9;&#x6837;&#x7684;API&#x3002;&#x4F8B;&#x5982;&#xFF1A;</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">declare</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">create</span>(<span class="hljs-params">o: object | <span class="hljs-literal">null</span></span>): <span class="hljs-title">void</span></span>;

create({ prop: <span class="hljs-number">0</span> }); <span class="hljs-comment">// OK</span>
create(<span class="hljs-literal">null</span>); <span class="hljs-comment">// OK</span>

create(<span class="hljs-number">42</span>); <span class="hljs-comment">// Error</span>
create(<span class="hljs-string">&quot;string&quot;</span>); <span class="hljs-comment">// Error</span>
create(<span class="hljs-literal">false</span>); <span class="hljs-comment">// Error</span>
create(<span class="hljs-literal">undefined</span>); <span class="hljs-comment">// Error</span>
</code></pre>
<h2 id="&#x652F;&#x6301;newtarget">&#x652F;&#x6301;<code>new.target</code></h2>
<p><code>new.target</code>&#x5143;&#x5C5E;&#x6027;&#x662F;ES2015&#x5F15;&#x5165;&#x7684;&#x65B0;&#x8BED;&#x6CD5;&#x3002;&#x5F53;&#x901A;&#x8FC7;<code>new</code>&#x6784;&#x9020;&#x51FD;&#x6570;&#x521B;&#x5EFA;&#x5B9E;&#x4F8B;&#x65F6;&#xFF0C;<code>new.target</code>&#x7684;&#x503C;&#x88AB;&#x8BBE;&#x7F6E;&#x4E3A;&#x5BF9;&#x6700;&#x521D;&#x7528;&#x4E8E;&#x5206;&#x914D;&#x5B9E;&#x4F8B;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7684;&#x5F15;&#x7528;&#x3002;&#x5982;&#x679C;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x4E0D;&#x662F;&#x901A;&#x8FC7;<code>new</code>&#x6784;&#x9020;&#x800C;&#x662F;&#x76F4;&#x63A5;&#x88AB;&#x8C03;&#x7528;&#xFF0C;&#x90A3;&#x4E48;<code>new.target</code>&#x7684;&#x503C;&#x88AB;&#x8BBE;&#x7F6E;&#x4E3A;<code>undefined</code>&#x3002;</p>
<p>&#x5F53;&#x5728;&#x7C7B;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#x4E2D;&#x9700;&#x8981;&#x8BBE;&#x7F6E;<code>Object.setPrototypeOf</code>&#x6216;<code>__proto__</code>&#x65F6;&#xFF0C;<code>new.target</code>&#x5C31;&#x6D3E;&#x4E0A;&#x7528;&#x573A;&#x4E86;&#x3002;&#x5728;NodeJS v4&#x53CA;&#x66F4;&#x9AD8;&#x7248;&#x672C;&#x4E2D;&#x7EE7;&#x627F;<code>Error</code>&#x7C7B;&#x5C31;&#x662F;&#x8FD9;&#x6837;&#x7684;&#x4F7F;&#x7528;&#x6848;&#x4F8B;&#x3002;</p>
<h4 id="&#x793A;&#x4F8B;">&#x793A;&#x4F8B;</h4>
<pre><code class="lang-typescript"><span class="hljs-keyword">class</span> CustomError extends <span class="hljs-built_in">Error</span> {
    <span class="hljs-keyword">constructor</span>(message?: string) {
        <span class="hljs-keyword">super</span>(message); <span class="hljs-comment">// &apos;Error&apos; breaks prototype chain here</span>
        <span class="hljs-built_in">Object</span>.setPrototypeOf(<span class="hljs-keyword">this</span>, <span class="hljs-keyword">new</span>.target.prototype); <span class="hljs-comment">// restore prototype chain</span>
    }
}
</code></pre>
<p>&#x751F;&#x6210;JS&#x4EE3;&#x7801;&#xFF1A;</p>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> CustomError = (<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">_super</span>) </span>{
  __extends(CustomError, _super);
  <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">CustomError</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">var</span> _newTarget = <span class="hljs-keyword">this</span>.constructor;
    <span class="hljs-keyword">var</span> _this = _super.apply(<span class="hljs-keyword">this</span>, <span class="hljs-built_in">arguments</span>);  <span class="hljs-comment">// &apos;Error&apos; breaks prototype chain here</span>
    _this.__proto__ = _newTarget.prototype; <span class="hljs-comment">// restore prototype chain</span>
    <span class="hljs-keyword">return</span> _this;
  }
  <span class="hljs-keyword">return</span> CustomError;
})(<span class="hljs-built_in">Error</span>);
</code></pre>
<p>new.target&#x4E5F;&#x9002;&#x7528;&#x4E8E;&#x7F16;&#x5199;&#x53EF;&#x6784;&#x9020;&#x7684;&#x51FD;&#x6570;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;</p>
<pre><code class="lang-typescript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">f</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">if</span> (<span class="hljs-keyword">new</span>.target) { <span class="hljs-comment">/* called via &apos;new&apos; */</span> }
}
</code></pre>
<p>&#x7F16;&#x8BD1;&#x4E3A;&#xFF1A;</p>
<pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">f</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">var</span> _newTarget = <span class="hljs-keyword">this</span> &amp;&amp; <span class="hljs-keyword">this</span> <span class="hljs-keyword">instanceof</span> f ? <span class="hljs-keyword">this</span>.constructor : <span class="hljs-keyword">void</span> <span class="hljs-number">0</span>;
  <span class="hljs-keyword">if</span> (_newTarget) { <span class="hljs-comment">/* called via &apos;new&apos; */</span> }
}
</code></pre>
<h2 id="&#x66F4;&#x597D;&#x5730;&#x68C0;&#x67E5;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x64CD;&#x4F5C;&#x6570;&#x4E2D;&#x7684;null--undefined">&#x66F4;&#x597D;&#x5730;&#x68C0;&#x67E5;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x64CD;&#x4F5C;&#x6570;&#x4E2D;&#x7684;<code>null</code> / <code>undefined</code></h2>
<p>TypeScript 2.2&#x6539;&#x8FDB;&#x4E86;&#x5BF9;&#x8868;&#x8FBE;&#x5F0F;&#x4E2D;&#x53EF;&#x7A7A;&#x64CD;&#x4F5C;&#x6570;&#x7684;&#x68C0;&#x67E5;&#x3002;&#x5177;&#x4F53;&#x6765;&#x8BF4;&#xFF0C;&#x8FD9;&#x4E9B;&#x73B0;&#x5728;&#x88AB;&#x6807;&#x8BB0;&#x4E3A;&#x9519;&#x8BEF;&#xFF1A;</p>
<ul>
<li>&#x5982;&#x679C;<code>+</code>&#x8FD0;&#x7B97;&#x7B26;&#x7684;&#x4EFB;&#x4F55;&#x4E00;&#x4E2A;&#x64CD;&#x4F5C;&#x6570;&#x662F;&#x53EF;&#x7A7A;&#x7684;&#xFF0C;&#x5E76;&#x4E14;&#x4E24;&#x4E2A;&#x64CD;&#x4F5C;&#x6570;&#x90FD;&#x4E0D;&#x662F;<code>any</code>&#x6216;<code>string</code>&#x7C7B;&#x578B;&#x3002;</li>
<li>&#x5982;&#x679C;<code>-</code>&#xFF0C;<code>*</code>&#xFF0C;<code>**</code>&#xFF0C;<code>/</code>&#xFF0C;<code>&#xFF05;</code>&#xFF0C;<code>&lt;&lt;</code>&#xFF0C;<code>&gt;&gt;</code>&#xFF0C;<code>&gt;&gt;&gt;</code>, <code>&amp;</code>, <code>|</code> &#x6216; <code>^</code>&#x8FD0;&#x7B97;&#x7B26;&#x7684;&#x4EFB;&#x4F55;&#x4E00;&#x4E2A;&#x64CD;&#x4F5C;&#x6570;&#x662F;&#x53EF;&#x7A7A;&#x7684;&#x3002;</li>
<li>&#x5982;&#x679C;<code>&lt;</code>&#xFF0C;<code>&gt;</code>&#xFF0C;<code>&lt;=</code>&#xFF0C;<code>&gt;=</code>&#x6216;<code>in</code>&#x8FD0;&#x7B97;&#x7B26;&#x7684;&#x4EFB;&#x4F55;&#x4E00;&#x4E2A;&#x64CD;&#x4F5C;&#x6570;&#x662F;&#x53EF;&#x7A7A;&#x7684;&#x3002;</li>
<li>&#x5982;&#x679C;<code>instanceof</code>&#x8FD0;&#x7B97;&#x7B26;&#x7684;&#x53F3;&#x64CD;&#x4F5C;&#x6570;&#x662F;&#x53EF;&#x7A7A;&#x7684;&#x3002;</li>
<li>&#x5982;&#x679C;&#x4E00;&#x5143;&#x8FD0;&#x7B97;&#x7B26;<code>+</code>&#xFF0C;<code>-</code>&#xFF0C;<code>~</code>&#xFF0C;<code>++</code>&#x6216;&#x8005;<code>--</code>&#x7684;&#x64CD;&#x4F5C;&#x6570;&#x662F;&#x53EF;&#x7A7A;&#x7684;&#x3002;</li>
</ul>
<p>&#x5982;&#x679C;&#x64CD;&#x4F5C;&#x6570;&#x7684;&#x7C7B;&#x578B;&#x662F;<code>null</code>&#x6216;<code>undefined</code>&#x6216;&#x8005;&#x5305;&#x542B;<code>null</code>&#x6216;<code>undefined</code>&#x7684;&#x8054;&#x5408;&#x7C7B;&#x578B;&#xFF0C;&#x5219;&#x64CD;&#x4F5C;&#x6570;&#x89C6;&#x4E3A;&#x53EF;&#x7A7A;&#x7684;&#x3002;&#x6CE8;&#x610F;&#xFF1A;&#x5305;&#x542B;<code>null</code>&#x6216;<code>undefined</code>&#x7684;&#x8054;&#x5408;&#x7C7B;&#x578B;&#x53EA;&#x4F1A;&#x51FA;&#x73B0;&#x5728;<code>--strictNullChecks</code>&#x6A21;&#x5F0F;&#x4E2D;&#xFF0C;&#x56E0;&#x4E3A;&#x5E38;&#x89C4;&#x7C7B;&#x578B;&#x68C0;&#x67E5;&#x6A21;&#x5F0F;&#x4E0B;<code>null</code>&#x548C;<code>undefined</code>&#x5728;&#x8054;&#x5408;&#x7C7B;&#x578B;&#x4E2D;&#x662F;&#x4E0D;&#x5B58;&#x5728;&#x7684;&#x3002;</p>
<h2 id="&#x5B57;&#x7B26;&#x4E32;&#x7D22;&#x5F15;&#x7B7E;&#x540D;&#x7C7B;&#x578B;&#x7684;&#x70B9;&#x5C5E;&#x6027;">&#x5B57;&#x7B26;&#x4E32;&#x7D22;&#x5F15;&#x7B7E;&#x540D;&#x7C7B;&#x578B;&#x7684;&#x70B9;&#x5C5E;&#x6027;</h2>
<p>&#x5177;&#x6709;&#x5B57;&#x7B26;&#x4E32;&#x7D22;&#x5F15;&#x7B7E;&#x540D;&#x7684;&#x7C7B;&#x578B;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>[]</code>&#x7B26;&#x53F7;&#x8BBF;&#x95EE;&#xFF0C;&#x4F46;&#x4E0D;&#x5141;&#x8BB8;&#x4F7F;&#x7528;<code>.</code>&#x7B26;&#x53F7;&#x8BBF;&#x95EE;&#x3002;&#x4ECE;TypeScript 2.2&#x5F00;&#x59CB;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;&#x90FD;&#x5141;&#x8BB8;&#x4F7F;&#x7528;&#x3002;</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">interface</span> StringMap&lt;T&gt; {
    [x: <span class="hljs-built_in">string</span>]: T;
}

<span class="hljs-keyword">const</span> map: StringMap&lt;<span class="hljs-built_in">number</span>&gt;;

map[<span class="hljs-string">&quot;prop1&quot;</span>] = <span class="hljs-number">1</span>;
map.prop2 = <span class="hljs-number">2</span>;
</code></pre>
<p>&#x8FD9;&#x4EC5;&#x9002;&#x7528;&#x4E8E;&#x5177;&#x6709;&#x663E;&#x5F0F;&#x5B57;&#x7B26;&#x4E32;&#x7D22;&#x5F15;&#x7B7E;&#x540D;&#x7684;&#x7C7B;&#x578B;&#x3002;&#x5728;&#x7C7B;&#x578B;&#x4F7F;&#x7528;&#x4E0A;&#x4F7F;&#x7528;<code>.</code>&#x7B26;&#x53F7;&#x8BBF;&#x95EE;&#x672A;&#x77E5;&#x5C5E;&#x6027;&#x4ECD;&#x7136;&#x662F;&#x4E00;&#x4E2A;&#x9519;&#x8BEF;&#x3002;</p>
<h2 id="&#x652F;&#x6301;&#x5728;jsx&#x5B50;&#x5143;&#x7D20;&#x4E0A;&#x4F7F;&#x7528;&#x6269;&#x5C55;&#x8FD0;&#x7B97;&#x7B26;">&#x652F;&#x6301;&#x5728;JSX&#x5B50;&#x5143;&#x7D20;&#x4E0A;&#x4F7F;&#x7528;&#x6269;&#x5C55;&#x8FD0;&#x7B97;&#x7B26;</h2>
<p>TypeScript 2.2&#x589E;&#x52A0;&#x4E86;&#x5BF9;&#x5728;JSX&#x5B50;&#x5143;&#x7D20;&#x4E0A;&#x4F7F;&#x7528;&#x6269;&#x5C55;&#x8FD0;&#x7B97;&#x7B26;&#x7684;&#x652F;&#x6301;&#x3002;&#x66F4;&#x591A;&#x8BE6;&#x60C5;&#x8BF7;&#x770B;<a href="https://github.com/facebook/jsx/issues/57" target="_blank">facebook/jsx#57</a>&#x3002;</p>
<h4 id="&#x793A;&#x4F8B;">&#x793A;&#x4F8B;</h4>
<pre><code class="lang-typescript">function Todo(prop: { key: number, todo: string }) {
    return &lt;div&gt;{prop.key.toString() + prop.todo}&lt;/div&gt;;
}

function TodoList({ todos }: TodoListProps) {
    return &lt;div&gt;
        {...todos.map(todo =&gt; &lt;Todo key={todo.id} todo={todo.todo} /&gt;)}
    &lt;/div&gt;;
}

let x: TodoListProps;

&lt;TodoList {...x} /&gt;
</code></pre>
<h2 id="&#x65B0;&#x7684;jsx-react-native">&#x65B0;&#x7684;<code>jsx: react-native</code></h2>
<p>React-native&#x6784;&#x5EFA;&#x7BA1;&#x9053;&#x671F;&#x671B;&#x6240;&#x6709;&#x6587;&#x4EF6;&#x90FD;&#x5177;&#x6709;.js&#x6269;&#x5C55;&#x540D;&#xFF0C;&#x5373;&#x4F7F;&#x8BE5;&#x6587;&#x4EF6;&#x5305;&#x542B;JSX&#x8BED;&#x6CD5;&#x3002;&#x65B0;&#x7684;<code>--jsx</code>&#x7F16;&#x8BD1;&#x53C2;&#x6570;&#x503C;<code>react-native</code>&#x5C06;&#x5728;&#x8F93;&#x51FA;&#x6587;&#x4EF6;&#x4E2D;&#x575A;&#x6301;JSX&#x8BED;&#x6CD5;&#xFF0C;&#x4F46;&#x662F;&#x7ED9;&#x5B83;&#x4E00;&#x4E2A;<code>.js</code>&#x6269;&#x5C55;&#x540D;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="TypeScript 2.3.html" class="navigation navigation-prev " aria-label="Previous page: TypeScript 2.3">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="TypeScript 2.1.html" class="navigation navigation-next " aria-label="Next page: TypeScript 2.1">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"TypeScript 2.2","level":"1.7.10","depth":2,"next":{"title":"TypeScript 2.1","level":"1.7.11","depth":2,"path":"doc/release-notes/TypeScript 2.1.md","ref":"./doc/release-notes/TypeScript 2.1.md","articles":[]},"previous":{"title":"TypeScript 2.3","level":"1.7.9","depth":2,"path":"doc/release-notes/TypeScript 2.3.md","ref":"./doc/release-notes/TypeScript 2.3.md","articles":[]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"Patrick Zhong","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"preface.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"TypeScript Handbook","language":"zh-hans","gitbook":">3.0.0","description":"Translation of official TypeScript Handbook"},"file":{"path":"doc/release-notes/TypeScript 2.2.md","mtime":"2018-10-13T09:48:54.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-13T09:57:42.904Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

